<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 <%@ include file="/commons/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-cache">
<title>新增艺术家_弹出框</title>
<link href="../style/css_member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/common.js"></script>
<script src="../js/artDialog.js?skin=gray"></script>
<script src="../js/artDialog.iframeTools.js"></script>
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>
<script type="text/javascript">

$(function(){
	$("#painterLink").click(function(){
		art.dialog.open('${ctx}/fileUpload!uploadPrepare.do?imgType=painter&sharpId=6',{title:'上传艺术家照片',width:800,height:550},false);
    });

    $("#englishName").blur(function(){
    	checkEnglishName();
     });
});

	/**********提交前检查表单*****************/
	function checkForm(){

		var name = $.trim($("#name").val());
		if( name  ==  ""){
			$("#name").focus();
			 alert("艺术家姓名不能为空。");
			 return false;
		}

		if(!checkEnglishName()){
			return false;
		}

		var picImage = $("#picImage").val();
		if( picImage == "" ){
			alert("请上传艺术家照片");
			return false;
		}

		var age = $("#age").val();
		if(!IsInt(age)){
			$("#age").val("");
			$("#age").focus();
			alert("请输入合法的出生年份");
			return false;
		}
		
		if(window.confirm("确认提交？")){
			$.ajax({
				type:'POST',
				url:'${ctx }/painter/save_additional.do',
				async : false, //ajax同步
				data:$("#painterForm").serialize(),//序列化表单里所有的内容
				success: function(data){
					 var arr = data.split(",");
					if(arr.length > 2 ){
						if(arr[0]=='0000'){
							var origin = art.dialog.open.origin;
							origin.document.getElementById('painter_id').value = arr[1];
			    			origin.document.getElementById('painter_name').value= arr[2];
			    			origin.listAvailablePainterList();
			    			alert("艺术家资料保存成功！");
			    			art.dialog.close();
						}
						else if(arr[0]=='0001'){
							alert("该艺术家已存在，不要重复添加！");
						}
					}else{
						alert("艺术家资料保存失败！");
						return false;
					}
				}
			});
		}
	}

	/**
	* 检查汉语拼音是否重复
	*/
	function checkEnglishName(){
        var englishName = $("#englishName").val();
        if(englishName == ""){
			alert("请填写艺术家姓名的汉语拼音。");
			return false;
        }
        return $.ajax({
			type:'POST',
			url:'${ctx }/front/painterAction!checkEnglishName.do?englishName='+englishName,
			async : false, //ajax同步
			success: function(data){
				var returnMsg = eval('('+data+')');
				if(returnMsg.code == '0000'){
					return true;
				}else{
					alert(returnMsg.message);
					return false;
				}
			}
		});
	}
	
</script>
</head>

<body>
<form action="${ctx }/painter/save_additional.do" method="post" id="painterForm">
<table width="800" border="0" cellspacing="0" cellpadding="0" align="center" style="border: 1px solid #ccc; background: #fff">
              <tr>
                <td colspan="100%" class="bt14A" align="center">补充艺术家资料</td>
              </tr>
              <tr>
	             <td class="bt14A" align="right"><span class="style15">*</span>艺术家姓名：</td>
	             <td class="bt14A">
	                  <input name="painter.name" type="text" size="20" id="name" value="${param.p_name }">
	                                               汉语拼音：<input name="painter.englishName" type="text" size="10" id="englishName"  value="${painter.englishName }" maxlength="40">
	             </td>
	             <td width="160" rowspan="10" valign="top" align="left">
                    <table width="150" height="184" border="0" cellpadding="0" cellspacing="1" bordercolor="#CCCCCC" bgcolor="#CCCCCC">
                      <tr>
                        <td bgcolor="#FFFFFF">
                        	 <div id="photoTd" style="width: 150px;height: 184px;vertical-align: middle;text-align: center;overflow: hidden;"></div>                        </td>
                      </tr>
                    </table>
                </td>
              </tr>
             <tr>
                <td class="bt14A"  align="right"></td>
                <td class="bt14A">字<input name="painter.zi" type="text" size="6">
                				   号<input name="painter.hao" type="text" size="6">
                </td>
                <td></td>
             </tr>
              <tr>
                <td class="bt14A" align="right"><span class="style15">*</span> 选择门类：</td>
                <td class="bt14A">
	                  <select name="painter.catalogType.id" id="catalogTypeSelect">
		         			<c:forEach items="${catalogTypeList}" var="catalogType" varStatus="status">
				            	 	<option value="${ catalogType.id}" <c:if test="${ param.c_id == catalogType.id}">selected="selected"</c:if>/> ${ catalogType.name}</option>
				           </c:forEach>
			     	  </select>	
                </td>
                <td></td>
              </tr>
              <tr>
                <td class="bt14A"  align="right"><div align="right"><span class="style15">*</span>艺术家照片：</div></td>
                <td class="bt14A"><div align="left"><span class="style18"><a id="painterLink" style="cursor: pointer;color: red">上传</a></span></div></td>
                <td></td>
              </tr>
              <tr>
                <td class="bt14A"  align="right"><span class="style15">*</span> 年 龄：</td>
                <td class="bt14A">
                  <input name="painter.age" type="text" size="3" id="age" maxlength="4">年生</td>
                  <td></td>
              </tr>
              <tr>
                <td class="bt14A" align="right">毕业院校：</td>
                <td class="bt14A"><input name="painter.graduatedFrom" type="text" size="30" id="graduatedFrom"></td>
             	<td></td>
              </tr>
              <tr>
                <td class="bt14A"  align="right">职业/头衔：</td>
                <td class="bt14A"><input name="painter.honour" type="text" size="40" id="honour" maxlength="100"></td>
               	<td></td>
                </tr>
              <tr>
                <td class="bt14A" align="right"><span class="style15">* </span>所在地：</td>
                <td class="bt14A">
                  <select name="painter.provinceInfo.id" id="provinceInfoSelect" onchange="changeProvince()">
                        <option value="">选择省份</option>
                        <c:forEach items="${provinceInfoList}" var="provinceInfo" varStatus="status">
				            <option value="${ provinceInfo.id}"/> ${ provinceInfo.name}</option>
				        </c:forEach>
                    </select>
                      <select name="painter.cityInfo.id" id="cityInfoSelect">
                        <option>选择县市</option>
                      </select>
                 </td>
                  <td></td>
              </tr>
              <tr>
                <td class="bt14A" align="right" valign="top"><span class="style15">*</span> 艺术人生：</td>
                <td style="padding-left: 5px;" colspan="2"><textarea rows="8" cols="70" name="painter.description"></textarea></td>
              </tr>
              <tr>
                <td width="160">
                	   <!-- 隐藏域 begin -->
			            <input name="painter.imageInfo.id" type="hidden"  id="picImage">
			            <input name="painter.type" type="hidden"  id="painter_type" value="1">
			            <!-- 隐藏域 end --> 
			     </td>
                <td colspan="2" style="padding: 15px 0px 20px 5px;">
                	<img src="../images/an24.gif" width="114" height="31" onClick="javascript:checkForm()" style="cursor: pointer ;border: 0"> 
                </td>
             </tr>
     </table>
</form>

</body>
</html>